package com.lxw.report.meta.query.queryer;

import com.lxw.report.engine.dataModel.report.ReportParameter;
import com.lxw.report.meta.entity.DataBase;
import com.lxw.report.meta.enums.DbPoolEnum;

import java.lang.reflect.Constructor;

/**
 * 报表查询器工厂方法类
 *
 * @author lxw
 */
public class QueryerFactory {
    public static Queryer create(DataBase DataBase) {
        if (DataBase != null) {
            try {
                 Class<?> clazz = Class.forName(DataBase.getPoolType());
                 Constructor<?> constructor = clazz.getConstructor(DataBase.class, ReportParameter.class);
                return (Queryer)constructor.newInstance(DataBase);
            } catch ( Exception ex) {
                throw new RuntimeException("create report queryer error", ex);
            }
        }
        return null;
    }
}
